package com.qqla.controller;


import com.qqla.dto.ChatRecordsPage;
import com.qqla.dto.InsertChatDto;
import com.qqla.enumeration.AppHttpCodeEnum;
import com.qqla.result.PageResult;
import com.qqla.result.ResponseResult;
import com.qqla.service.ChatService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user/chat")
@RequiredArgsConstructor
public class ChatController {

    private final ChatService chatService;

    // 获取聊天记录
    @PostMapping("records")
    public ResponseResult getChatList(@RequestBody ChatRecordsPage chatRecordsPage) {
        PageResult chatList = chatService.getChatList(chatRecordsPage);
        return ResponseResult.okResult(chatList);
    }

    /*
    * 新增聊天记录
    * */
    @PostMapping("/insert")
    public ResponseResult insert(@RequestBody InsertChatDto dto) {
        chatService.insertRecords(dto);
        return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
    }
}
